package com.qf.controller;

import org.apache.commons.io.IOUtils;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.*;

@Controller
@RequestMapping("/system/res")
public class ResourceController {
    @RequestMapping("/getImage")
    @ResponseBody
    public void getImage(String path, HttpServletResponse response){
        try (
            InputStream is = new FileInputStream(path);
            OutputStream os = response.getOutputStream();
        ){
            IOUtils.copy(is,os);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
